package com.mask.im.business.common.util;

import com.mask.im.business.model.dto.EmailDTO;
import com.mask.im.business.model.vo.MallVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.thymeleaf.TemplateEngine;

import javax.annotation.Resource;

@Slf4j
@Component
public class EmailUtil{

//    @Value("${spring.mail.username}")
//    private String email;

//    @Resource
//    private JavaMailSender javaMailSender;

//    @Resource
//    private JavaMailSenderImpl mailSender;

    @Resource
    private TemplateEngine templateEngine;

    public void sendHtmlMail(EmailDTO emailDTO) {
//        try {
////            MimeMessage mimeMessage = javaMailSender.createMimeMessage();
////            MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage);
////            Context context = new Context();
////            context.setVariables(emailDTO.getCommentMap());
////            String process = templateEngine.process(emailDTO.getTemplate(), context);
////            mimeMessageHelper.setFrom(email);
////            mimeMessageHelper.setTo(emailDTO.getEmail());
////            mimeMessageHelper.setSubject(emailDTO.getSubject());
////            mimeMessageHelper.setText(process, true);
////            javaMailSender.send(mimeMessage);
//        } catch (MessagingException e) {
//            e.printStackTrace();
//        }
    }
    public void sendSimpleMail(MallVO emailDTO) {
//        try {
//            SimpleMailMessage mailMessage= new SimpleMailMessage();
//            mailMessage.setFrom(email);
//            mailMessage.setTo(emailDTO.getEmail());
//            mailMessage.setSubject(emailDTO.getTheme());
//            mailMessage.setText(emailDTO.getContext());
//            mailSender.send(mailMessage);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
}
